package com.fanix5.javamvvm.Ext;

import android.text.TextUtils;
import android.widget.ImageView;

import androidx.appcompat.widget.AppCompatTextView;
import androidx.databinding.BindingAdapter;

import com.bumptech.glide.Glide;
import com.fanix5.javamvvm.R;

public class BindingAdapterExt {

    @BindingAdapter("imageUrl")
    public static void setSrc(ImageView imageView,String url){
        Glide.with(imageView.getContext()).load(url)
                .placeholder(R.drawable.ic_img_placeholder)
                .into(imageView);
    }

    @BindingAdapter("loadText")
    public static void setText(AppCompatTextView textView,String text){
        String str = text;
        if( TextUtils.equals("   ",text) || TextUtils.equals("  ",text) || TextUtils.equals(" ",text) || TextUtils.isEmpty(text)){
            str = "哈哈";
        }
        textView.setText(str);
    }

}
